package com.leanin.form.contoller;

import com.leanin.form.model.request.FollowFormDTO;
import com.leanin.form.model.request.FormQueryDTO;
import com.leanin.form.model.response.CommonResponseResult;
import com.leanin.form.model.response.QueryResponseResult;
import com.leanin.form.model.response.ResponseResult;
import com.leanin.form.service.FollowFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author CPJ.
 * @date 2019/6/14.
 * @time 15:13.
 */
@RestController
@RequestMapping("/followForm")
public class FollowFormController {

    @Autowired
    private FollowFormService followFormService;

    /**
     * 添加随访表单
     * @param followFormDTO
     * @return
     */
    @PostMapping("/addFollowForm")
    public ResponseResult addFollowForm(@RequestBody FollowFormDTO followFormDTO){
        return followFormService.addFollowForm(followFormDTO);
    }

    /**
     * 修改随访表单
     * @param followFormDTO
     * @return
     */
    @PutMapping("/updateFollowForm")
    public ResponseResult updateFollowForm(@RequestBody FollowFormDTO followFormDTO){
        return followFormService.updateFollowForm(followFormDTO);
    }

    /**
     * 条件查询随访表单
     * @param formQueryDTO
     * @return
     */
    @PostMapping("/findByParam")
    public QueryResponseResult findByParam(@RequestBody FormQueryDTO formQueryDTO){
        return followFormService.findByParam(formQueryDTO);
    }

    /**
     * 根据id查询随访表单信息
     * @param formId 随访表单id
     * @return
     */
    @GetMapping("/findById")
    public CommonResponseResult findById(@RequestParam("formId")Long formId){
        return followFormService.findById(formId);
    }

    /**
     * 添加下载次数
     * @param formId 表单id
     * @return
     */
    @GetMapping("/addDownLoadCount")
    public ResponseResult addDownLoadCount(@RequestParam("formId") Long formId){
        return followFormService.addDownLoadCount(formId);
    }

    /**
     * 删除表单
     * @param formId
     * @return
     */
    @DeleteMapping("/deleteForm")
    public ResponseResult deleteForm(@RequestParam("formId") Long formId){
        return followFormService.deleteForm(formId);
    }


}
